package main

import "fmt"

type Pay interface {
	PayPage(price int64) string
}
type AliPay struct{}

func (a AliPay) PayPage(price int64) string {
	return "支付宝支付"
}

type WxPay struct{}

func (w WxPay) PayPage(price int64) string {
	return "微信支付"
}

type YlPay struct{}

func (y YlPay) PayPage(price int64) string {
	return "银联支付"
}

//类的数量会增加 系统复杂性会增加

// PayFactory 支付工厂接口 工厂负责创建产品
type PayFactory interface {
	CreatePay() Pay
}
type YlPayFactory struct{}

func (y YlPayFactory) CreatePay() Pay {
	return YlPay{}
}

// AliPayFactory 阿里支付工厂
type AliPayFactory struct{}

func (a AliPayFactory) CreatePay() Pay {
	return AliPay{}
}

// WxPayFactory 微信支付工厂
type WxPayFactory struct{}

func (w WxPayFactory) CreatePay() Pay {
	return WxPay{}
}
func main() {
	factory := YlPayFactory{}
	//返回具体的支付产品
	pay := factory.CreatePay()
	fmt.Println(pay.PayPage(23))
}
